package semSimilarity.sentence;

import java.util.List;

import semSimilarity.SimilarityGenerator;
import semSimilarity.SimilarityMatrix;
import semSimilarity.word.SimilarityCacheSimulator;
import semSimilarity.word.WordSimilarity;
import sentStruct.PartOfSpeech;

public class PartOfSpeechSimGenerator implements SimilarityGenerator<PartOfSpeech>{
	
	
	
	public double similarity(PartOfSpeech p1, PartOfSpeech p2){
		if (p1==null||p2==null)
			return 0;
			
		WordSimilarity ws = new SimilarityCacheSimulator();
		//WordSimilarity ws = SparqlWNTest.getInstance();
		double sim = ws.generateWordSimilarity(p1.getValue(), p2.getValue());
		if ((p1.isNegative()||p2.isNegative())&&!(p1.isNegative()&&p2.isNegative())) // XOR
			sim*=-1;
		
		
		return sim;
	}
	
	
	@Override
	public double similarity(List<? extends PartOfSpeech> l1, List<? extends PartOfSpeech> l2){
		if (l1==null||l2==null||l1.size()==0||l2.size()==0)
			return 0;
		
		SimilarityMatrix<PartOfSpeech> simMatrix = new SimilarityMatrix<PartOfSpeech>(l1, l2, this);
		
	
	
		return simMatrix.maxSimilarityAverage();
	}




}
